package day0927;

import java.util.Comparator;
import java.util.TreeSet;

class Phone{
    int  weight;
}
class ZYQC  implements Comparator<Phone>{//1.比较器类
    public int compare(Phone o1, Phone o2) {
        return o2.weight-o1.weight;//升序：  参数1的值 -  参数2的值
    }
}
public class S1 {
    public static void main(String[] args) {
        TreeSet<Phone>  set=new TreeSet(  new ZYQC()   );
        Phone mate30=new Phone();  mate30.weight=430;  set.add(mate30);
        Phone iphone30=new Phone();  iphone30.weight=290; set.add(iphone30);

        for(Phone p:set){//用于打印
            System.out.println("p.weight = " + p.weight);//用于打印
        }//用于打印
    }
}
